#include <my_header.h>

void * threadFunc(void *arg)
{
    int * num = (int *)arg;
    printf("I am %d Child thread.\n",*num);
    return (void *)(long)num;
}

/* usage */
int main(int argc, char *argv[])
{
    ARGS_CHECK(argc,1);

    pthread_t tid[3];
    int thread_args[3];
    for(int i = 0;i < 3;i++)
    {
        thread_args[i] = i;
        int ret_create = pthread_create(&tid[i],NULL,threadFunc,&thread_args[i]);
        THREAD_ERROR_CHECK(ret_create,"pthread_create");
    }

    for(int i = 0;i < 3;i++)
    {
        void *ret;
        int ret_join = pthread_join(tid[i],&ret);
        THREAD_ERROR_CHECK(ret_join,"pthread_join");
        printf("child %d pthread retval = %ld\n",i,(long)ret);
    }
    return 0;
}

